// 同一管理咱们项目用户相关的接口
import request from "@/utils/request";
import type{checkPwdResponseData,  loginFormData,loginResponseData,pwdData,userAllResponesData,userInfoData,userInfoReponseData, userListFormData, userListResponesData} from './type.ts'
// 项目相关的请求地址
// @ts-ignore
enum API{
    LOGIN_URL='/login',
    USERINFO_URL='/user/info',
    LOGOUT_URL='/loginout',
    CHECK_PWD_URL="/manage/user/pwd",
    USER_ALL_URL="/manage/user/all",
    USER_LIST_URL="/manage/user/list",
    USER_ADD_URL="/manage/user/add",
    USER_GET_ID_URL="/manage/user/find",
    USER_UPDATA_URL="/manage/user/update",
    USER_DELETE_UPL="/manage/user/delete"
}
// 登录接口
export const reqLogin =(data:loginFormData)=>request.post<any,loginResponseData>(API.LOGIN_URL,data)
// 获取用户信息
export const reqUserInfo=()=>request.post<any,userInfoReponseData>(API.USERINFO_URL)
// 退出登录
export const reqLogout=()=>request.post<any,any>(API.LOGOUT_URL)
// 校验密码
export const reqCheckPwd =(data:pwdData)=>request.post<any,checkPwdResponseData>(API.CHECK_PWD_URL,data)
// 修改密码
export const reqUpdatePwd =(data:pwdData)=>request.put<any,checkPwdResponseData>(API.CHECK_PWD_URL,data)
// 获取所有用户列表
export const reqUserAll = ()=>request.get<any,userAllResponesData>(API.USER_ALL_URL)
// 获取分页用户列表
export const reqUserList = (data:userListFormData)=>request.post<any,userListResponesData>(API.USER_LIST_URL,data)
// 添加用户
export const reqAddUser = (data:userInfoData)=>request.post<any,loginResponseData>(API.USER_ADD_URL,data)
// 根据id查询用户
export const reqUserById = (_id:string)=>request.get<any,loginResponseData>(API.USER_GET_ID_URL +`?_id=${_id}`)
// 修改用户信息
export const reqUserUpdate = (data:userInfoData)=>request.post<any,loginResponseData>(API.USER_UPDATA_URL,data)
// 删除用户
export const reqUserDelete = (userId:string)=>request.post<any,loginResponseData>(API.USER_DELETE_UPL,{userId})